<%= form_for [:shop, @fare_template, @fare_mode], html: { class: "card" } do |f| %>
  <div class="card-body">
    <h3 class="card-title">
      <%= @fare_mode.new_record? ? "新增运费" : "修改运费" %>
    </h3>
    <div class="row">
      <% if @fare_template.location? %>
      <div class="col-md-12">
        <div class="form-group">
          <label class="form-label">配送范围</label>
          <% if @fare_mode.is_default %>
            <div class="form-control-plaintext">全国默认地区</div>
          <% else %>
            <%= f.select :province_ids, Province.all.select('id, name').map{ |c| [c.name, c.id] }, { include_blank: '请选择配送区域' }, { class: 'form-control select', multiple: "multiple" } %>
          <% end %>
        </div>
      </div>
      <% elsif @fare_template.distance? %>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">开始距离（单位：公里)</label>
          <%= f.number_field :min_distance, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">结束距离（单位：公里)</label>
          <%= f.number_field :max_distance, class: "form-control" %>
        </div>
      </div>
      <% elsif @fare_template.weight? %>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">开始重量（单位：公斤)</label>
          <%= f.number_field :min_weight, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">结束重量（单位：公斤)</label>
          <%= f.number_field :max_weight, class: "form-control" %>
        </div>
      </div>
      <% end %>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">首N件</label>
          <%= f.number_field :first_n_piece, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">首费</label>
          <%= f.number_field :first_amount, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">续M件</label>
          <%= f.number_field :second_n_piece, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">续费</label>
          <%= f.number_field :second_amount, class: "form-control" %>
        </div>
      </div>
    </div>
  </div>
  <div class="card-footer text-right">
    <%= f.submit "保 存", class: "btn btn-primary" %>
  </div>
<% end %>